<!DOCTYPE html>
<html>
<head>
    {include file='public/meta'/}
</head>
<body>

{include file='public/header'/}
<!------------------导航-------------------------->
<section>
    {include file='public/left'/}
    <!--------------------------主要内容区域------------------------------------->
    <div class="content">
        <div class="page-heading mgl15 mgr15">
            <ul class="breadcrumb">
                <li>当前位置是&nbsp;:&nbsp;</li>
                <li><a href="#">微信管理</a></li>
                <li class="active" style="color: #02b87f;"> 模版消息管理</li>
            </ul>
        </div>
        <div class="panel panel-default mgl15 mgr15">
            <div class="panel-body">

                <div id="myTabContent" class="tab-content">
                    <div class="tab-pane active in" id="home">
                        {eq name="momach.auth_type" value="0"}
                        <div class="alert alert-danger" role="alert">
                            请绑定授权公众号并开通模板消息之后再来设置模版消息。
                        </div>
                        {else}

                        <div class="panel panel-default">
                            <div class="panel-heading">
                                <h3 class="panel-title">第一步：开通模板消息</h3>
                            </div>
                            <div class="panel-body">
                                <div class="alert alert-danger" role="alert">
                                    登陆微信公众号管理后台并找到左边菜单“添加功能插件”，进入模板消息功能模块后点申请，按要求完成申请信息填写并提交（注意！在此申请时就可以设置行业了。）
                                </div>

                            </div>
                        </div>
                        <div class="panel panel-default">
                            <div class="panel-heading">
                                <h3 class="panel-title">第二步：设置行业</h3>
                            </div>
                            <div class="panel-body">
                                <div class="alert alert-danger" role="alert">
                                    未设置行业和行业设置不对的可通过该步骤重新设置行业。
                                </div>
                                <form class="form-horizontal" name="form" id="form" style="max-width: 900px;">
                                    <div class="form-group">
                                        <label class="control-label col-sm-3">设置行业(一)：</label>
                                        <div class="col-sm-9">
                                            <input type="text" class="form-control" placeholder="点击设置获取"
                                                   value="互联网/电子商务">
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="control-label col-sm-3">设置行业(二)：</label>
                                        <div class="col-sm-9">
                                            <input type="text" class="form-control" placeholder="点击设置获取"
                                                   value="IT软件与服务">
                                        </div>
                                    </div>
                                    <div class="form-group text-center">
                                        <span class="btn btn-default" id="sethy">设置</span>
                                    </div>
                                </form>
                            </div>
                        </div>
                        <div class="panel panel-default">
                            <div class="panel-heading">
                                <h3 class="panel-title">第三步：设置模版消息</h3>
                            </div>
                            <div class="panel-body">
                                <div class="alert alert-danger" role="alert">
                                    收到成功提示后刷新可查看。
                                </div>
                                <form class="form-horizontal" name="form" style="max-width: 900px;">
                                    <div class="form-group">
                                        <label class="control-label col-sm-3">消费通知模板：</label>
                                        <div class="col-sm-9">
                                            <div class="input-group">
                                                <input type="text" class="form-control" placeholder="点击设置获取"
                                                       value="{$paytpl.template_id}">
                                                <span class="input-group-btn">
                                                {empty name="paytpl.template_id"}
                                                <button class="btn btn-default" name="pay_tpl" id="message"
                                                        onclick="setValue('pay_tpl','message')" type="button">
                                                    设置
                                                </button>
                                                {else/}
                                                <a class="btn btn-default">
                                                    已设置
                                                </a>
                                                {/empty}
                                            </span>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="control-label col-sm-3">余额变动模板：</label>
                                        <div class="col-sm-9">
                                            <div class="input-group">
                                                <input type="text" class="form-control" placeholder="点击设置获取"
                                                       value="{$yetpl.template_id}">
                                                <span class="input-group-btn">
                                                {empty name="$yetpl.template_id"}
                                                <button class="btn btn-default" name="card_ye_tpl" id="yue"
                                                        onclick="setValue('card_ye_tpl','yue')" type="button">
                                                    设置
                                                </button>
                                                 {else}
                                                   <a class="btn btn-default">
                                                    已设置
                                                </a>
                                                    {/empty}
                                            </span>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="control-label col-sm-3">礼品赠送模版：</label>
                                        <div class="col-sm-9">
                                            <div class="input-group">
                                                <input type="text" class="form-control" placeholder="点击设置获取"
                                                       value="{$zstpl.template_id}">
                                                <span class="input-group-btn">
                                                {empty name="$zstpl.template_id"}
                                                <button class="btn btn-default" name="card_zs_tpl" id="gift"
                                                        onclick="setValue('card_zs_tpl','gift')" type="button">
                                                    设置
                                                </button>
                                                 {else/}
                                                <a class="btn btn-default">
                                                    已设置
                                                </a>
                                                {/empty}
                                            </span>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="control-label col-sm-3">报表通知模版：</label>
                                        <div class="col-sm-9">
                                            <div class="input-group">
                                                <input type="text" class="form-control" placeholder="点击设置获取"
                                                       value="{$bbtpl.template_id}">
                                                <span class="input-group-btn">
                                                {empty name="$bbtpl.template_id"}
                                                <button class="btn btn-default" name="pre_man_tpl" id="pre"
                                                        onclick="setValue('pre_man_tpl','pre')" type="button">
                                                    设置
                                                </button>
                                                 {else/}
                                                <a class="btn btn-default">
                                                    已设置
                                                </a>
                                                {/empty}
                                            </span>
                                            </div>
                                        </div>
                                    </div>
                                </form>
                            </div>
                        </div>
                        {/eq}

                    </div>
                </div>

            </div>
        </div>
        {include file='public/footer'/}
    </div>
</section>

</body>

<script>
    function setValue(type, id) {
        $("#"+id).prop("disable",true);
        $("#"+id).prop("onclick",null).off("click");
        console.log($("#"+id));
                $.ajax({
                    url: "{:url('wxsystem/gettemlpid')}",
                    type: "post",
                    data: {
                        type: type
                    },

                    success: function (data) {
                        console.log(data);
                        if (data.code == "0") {
                            window.location.reload();
                            layer.msg("设置成功", {icon: 1});
                            $("#" + id).val(data.data);
                            return false;
                        } else {
                            layer.alert(data.message, {icon: 7});
                        }
                    }
                })

    }

    $(function () {
        $("#sethy").click(function () {
            layer.confirm('是否设置该行业？', {
                btn: ['确认', '取消'] //按钮
            }, function () {
                $.ajax({
                    url: "{:url('wxsystem/setindustry')}",
                    type: "post",
                    success: function (data) {
                        console.log(data);
                        if (data.code == "0") {
                            layer.msg("设置成功", {icon: 1});
                            $("#" + id).val(data.data);
                            return false;
                        } else {
                            layer.alert("使用次数受限,请去微信平台进行重置！", {icon: 7});
                        }
                    }
                })
            }, function () {
                layer.msg('您已取消!', {
                    time: 500, //20s后自动关闭
                });
            });

        })
    })
</script>
</html>


